From 7e78d75e7ad1ebcbbbc8ad134e01176b4ab7dfe5 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Sat, 18 Feb 2012 19:28:21 +0100 Subject: [PATCH] entry: don't force zero Y coordinate for insertion cursor Subclasses of GtkEntry could set a larger height request, so we need to apply the same calculations to the insertion cursors than we do on the PangoLayout to render it centered under all circumstances. --- gtk/gtkentry.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index d201affe8c..801dd96da5 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -5869,12 +5869,14 @@ gtk_entry_draw_cursor (GtkEntry *entry, gboolean block_at_line_end; PangoLayout *layout; const char *text; + gint x, y; context = gtk_widget_get_style_context (widget); layout = gtk_entry_ensure_layout (entry, TRUE); text = pango_layout_get_text (layout); cursor_index = g_utf8_offset_to_pointer (text, priv->current_pos + priv->preedit_cursor) - text; + get_layout_position (entry, &x, &y); if (!priv->overwrite_mode) block = FALSE; @@ -5885,19 +5887,16 @@ gtk_entry_draw_cursor (GtkEntry *entry, if (!block) { gtk_render_insertion_cursor (context, cr, - - priv->scroll_offset, 0, + x, y, layout, cursor_index, priv->resolved_dir); } else /* overwrite_mode */ { GdkRGBA cursor_color; GdkRectangle rect; - gint x, y; cairo_save (cr); - get_layout_position (entry, &x, &y); - rect.x = PANGO_PIXELS (cursor_rect.x) + x; rect.y = PANGO_PIXELS (cursor_rect.y) + y; rect.width = PANGO_PIXELS (cursor_rect.width); -- 2.30.2